package cms.simmytech.util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class test {
	// simmytech.document.type=doc,docx,txt,pdf,ppt
	// simmytech.image.type=jpg,jpeg,png
	// simmytech.video.type=mp4,jpeg,png

	private String documentType = "doc,docx,txt,pdf,ppt";

	private String imageType = "jpg,jpeg,png";

	private String videoType = "mp4,jpeg,png";

	private final static byte DOCUMENT_TYPE = 1;

	private final static byte IMAGE_TYPE = 2;

	private final static byte VIDEO_TYPE = 3;

	private static Map<Byte, Set<String>> FILE_INFO_MAP = new HashMap<Byte, Set<String>>();

	private static Set<String> getTypeSet(String typeString) {
		if (StringUtils.isEmpty(typeString)) {
			return null;
		}
		String[] types = typeString.split(",");
		Set<String> set = new HashSet<>(types.length);
		for (String string : types) {
			set.add(string);
		}
		return set;

	}

	public void goo() {
		// 文档类型
		Set<String> dSet = getTypeSet(documentType);
		if (null != dSet && dSet.size() > 0) {
			FILE_INFO_MAP.put(DOCUMENT_TYPE, dSet);
		}
		// 图片类型
		Set<String> iSet = getTypeSet(imageType);
		if (null != iSet && iSet.size() > 0) {
			FILE_INFO_MAP.put(IMAGE_TYPE, iSet);
		}
		// 视频类型
		Set<String> vSet = getTypeSet(videoType);
		if (null != vSet && vSet.size() > 0) {
			FILE_INFO_MAP.put(VIDEO_TYPE, vSet);
		} // 此静态方法供外部直接访问
	}

	public static test getInstance() {
		return Inner.instance;
	}

	private static class Inner {

		private static final test instance = new test();
	}

	/**
	 * main函数.
	 * 
	 * @param args
	 *            启动参数
	 * @throws Exception
	 *             Exception
	 */
	public static void main(String... args) throws Exception {
		test.getInstance().goo();
		System.out.println(FILE_INFO_MAP);
	}

}
